package com.ruoyi.znjc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.znjc.domain.ZnjcModelwarnlog;
import com.ruoyi.znjc.service.IZnjcModelwarnlogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型预警日志Controller
 * 
 * @author ZNJC
 * @date 2025-07-23
 */
@RestController
@RequestMapping("/znjc/modelwarnlog")
public class ZnjcModelwarnlogController extends BaseController
{
    @Autowired
    private IZnjcModelwarnlogService znjcModelwarnlogService;

    /**
     * 查询模型预警日志列表
     */
    @PreAuthorize("@ss.hasPermi('znjc:modelwarnlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZnjcModelwarnlog znjcModelwarnlog)
    {
        startPage();
        List<ZnjcModelwarnlog> list = znjcModelwarnlogService.selectZnjcModelwarnlogList(znjcModelwarnlog);
        return getDataTable(list);
    }

    /**
     * 导出模型预警日志列表
     */
    @PreAuthorize("@ss.hasPermi('znjc:modelwarnlog:export')")
    @Log(title = "模型预警日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZnjcModelwarnlog znjcModelwarnlog)
    {
        List<ZnjcModelwarnlog> list = znjcModelwarnlogService.selectZnjcModelwarnlogList(znjcModelwarnlog);
        ExcelUtil<ZnjcModelwarnlog> util = new ExcelUtil<ZnjcModelwarnlog>(ZnjcModelwarnlog.class);
        util.exportExcel(response, list, "模型预警日志数据");
    }

    /**
     * 获取模型预警日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('znjc:modelwarnlog:query')")
    @GetMapping(value = "/{warningId}")
    public AjaxResult getInfo(@PathVariable("warningId") Long warningId)
    {
        return success(znjcModelwarnlogService.selectZnjcModelwarnlogByWarningId(warningId));
    }

    /**
     * 新增模型预警日志
     */
    @PreAuthorize("@ss.hasPermi('znjc:modelwarnlog:add')")
    @Log(title = "模型预警日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZnjcModelwarnlog znjcModelwarnlog)
    {
        return toAjax(znjcModelwarnlogService.insertZnjcModelwarnlog(znjcModelwarnlog));
    }

    /**
     * 修改模型预警日志
     */
    @PreAuthorize("@ss.hasPermi('znjc:modelwarnlog:edit')")
    @Log(title = "模型预警日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZnjcModelwarnlog znjcModelwarnlog)
    {
        return toAjax(znjcModelwarnlogService.updateZnjcModelwarnlog(znjcModelwarnlog));
    }

    /**
     * 删除模型预警日志
     */
    @PreAuthorize("@ss.hasPermi('znjc:modelwarnlog:remove')")
    @Log(title = "模型预警日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warningIds}")
    public AjaxResult remove(@PathVariable Long[] warningIds)
    {
        return toAjax(znjcModelwarnlogService.deleteZnjcModelwarnlogByWarningIds(warningIds));
    }
}
